package com.fieldchain.ex.fa100.utils.share;


import com.fieldchain.ex.fa100.bean.BankChoseBean;
import com.fieldchain.ex.fa100.bean.CookieBean;
import com.fieldchain.ex.fa100.bean.User;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by biyunlong on 2016/9/4.
 */
public class ShareManager {
    private static ShareManager shareManager;
    private static String key="base_alicms";
    private final String saveScreenWidth = "SCREEN_WIDTH";
    private final String saveScreenHeight = "SCREEN_HEIGHT";

    private final String saveCoinType = "SAVECOINTYPE";
    private final String saveUser = "USER";
    private final String deviceId = "DEVICEID";
    private final String cookeis = "COOKEIS";
    private final String bankList = "BANKLIST";
    private String saveLoginNum="SAVELOGINNUM";
    private String bilv="bilv";

    public static ShareManager getInstance() {
        if (null == shareManager) {
            shareManager = new ShareManager();
        }
        return shareManager;
    }

    /*
     *  数据保存 :手机屏幕信息
     */
    public void saveWidth(int width) {
        ShareUtils.getInstance().saveObject(saveScreenWidth, width);
    }

    public int getWidth() {
        return ShareUtils.getInstance().getInt(saveScreenWidth);
    }


    public void saveDeviceId(String msg) {
        ShareUtils.getInstance().saveObject(deviceId, msg);
    }

    public String getDeviceId() {
        return ShareUtils.getInstance().getString(deviceId);
    }

    public void saveHeight(int height) {
        ShareUtils.getInstance().saveObject(saveScreenHeight, height);
    }

    public int getLoginNum() {
        return ShareUtils.getInstance().getInt(saveLoginNum);
    }

    public void setLoginNum(int num) {
        ShareUtils.getInstance().saveObject(saveLoginNum, num);
    }

    public int getHeight() {
        return ShareUtils.getInstance().getInt(saveScreenHeight);
    }
    public void saveCoinType(String type) {
        ShareUtils.getInstance().saveObject(saveCoinType, type);
    }

    public String getCoinType() {
        return ShareUtils.getInstance().getString(saveCoinType,"cnz");
    }


    public void clearUser() {
        ShareUtils.getInstance().clear(saveUser);
    }

    public void saveUser(User user) {
        ShareUtils.getInstance().saveData(saveUser, user);
    }

    public User getUser() {
        return (User) ShareUtils.getInstance().getData(saveUser);
    }


    public void saveCookei(List<CookieBean> cookieBean) {
        ShareUtils.getInstance().saveData(cookeis, cookieBean);
    }
    public List<CookieBean> getCookei() {
        List<CookieBean>list=(List<CookieBean>) ShareUtils.getInstance().getData(cookeis);
        return list!=null?list:new ArrayList<CookieBean>();
    }

    public void clearCookei(){
        ShareUtils.getInstance().clear(cookeis);
    }

    public void setBanckList(List<BankChoseBean> list){
        ShareUtils.getInstance().saveData(bankList, list);
    }

    public List<BankChoseBean> getBanckList(){
        return (List<BankChoseBean>) ShareUtils.getInstance().getData(bankList);
    }

    /*
     *  数据保存 :手机屏幕信息
     */
    public void saveLv(float lv) {
        ShareUtils.getInstance().saveObject(bilv, lv);
    }

    public float getLv() {
        return ShareUtils.getInstance().getFloat(bilv);
    }

}
